﻿using ManagoMes.Read.API.Applications.ProductionWorkOrders;
using MangoMes.Commont.DTOs;
using MangoMes.Commont.DTOs.ProductDTOs;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace ManagoMes.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class WorkOrdersController : ControllerBase
    {
        /// <summary>
        /// 生产构造函数
        /// </summary>
        private readonly IMediator _mediator;

        public WorkOrdersController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 生产工单分页列表
        /// </summary>
        /// <param name="info">查询条件</param>
        /// <returns>返回满足条件的数据</returns>
        [HttpPost]
        public async Task<CodePageDTO<ProductDTOs>> PageProductionList(ProductionOrdersListCommand info)
        {
            try
            {
                var list = await _mediator.Send(info);
                return list;
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 生产工单反填
        /// </summary>
        /// <param name="info">工单编码</param>
        /// <returns>返回满足条件的数据</returns>
        [HttpPost]
        public async Task<ResultsDTO<ProductionBackDTO>> PageProductionBack(ProductionOrdersBackfillCommand info)
        {
            try
            {
                var list = await _mediator.Send(info);
                return list;
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 待检任务
        /// </summary>
        /// <param name="info">工单编码</param>
        /// <returns>返回满足条件的数据</returns>
        [HttpPost]
        public async Task<CodePageDTO<InspectedListDTO>> InspectedList(InspectedListCommand info)
        {
            try
            {
                var list = await _mediator.Send(info);
                return list;
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 库存清单
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageDTO<InventoryListDTO>> InventoryList(InventoryCommand info)
        {
            try
            {
                var list = await _mediator.Send(info);
                return list;
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
